import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
// From http://www.java-forums.org/java-io/7215-how-get-count-all-lines-file.html
class LineCounter implements Runnable { 

		SweepViewGui sweepViewGui;
	   public LineCounter(SweepViewGui sweepViewGui) {
		   this.sweepViewGui = sweepViewGui;
		   System.out.println("---- Instancing Line Counter -----");		    	  
	   }

	   public  void run()  {
		   LineNumberReader lineNumberReader = null;
		   while (lineNumberReader == null)
		   {
			   System.out.println("----  Line Number Reader -----");		    
			   try 
			   {
				   System.out.println(new File(".").getAbsolutePath());
				   System.out.println(java.util.Arrays.deepToString(new File(".").list()));
				   File file = new File("./experiment.csv");
				   System.out.println(file.lastModified());
				   System.out.println(file.length());
				   FileInputStream fileInputStream = new FileInputStream("./experiment.csv");
				   lineNumberReader = new LineNumberReader(new InputStreamReader(fileInputStream));
				   try {System.out.println("Content:\n" + lineNumberReader.readLine());} 
				   catch (IOException e) {System.out.println("----  Not Read A-----");	}
			   } 
			   catch (FileNotFoundException e) 
			   {
				   e.printStackTrace();
				   System.out.println("----  File not there yet -----");		    		
			   }
			   try {Thread.sleep(500);} catch (InterruptedException e) {e.printStackTrace();}
		   }

		while (lineNumberReader.getLineNumber() < 7)
			   {
			   		System.out.println("Line Number: " + lineNumberReader.getLineNumber());
			   		try {System.out.println("Content:\n" + lineNumberReader.readLine());} 
			   		catch (IOException e) {System.out.println("----  Not Read B-----");}
			   		try {Thread.sleep(500);} catch (InterruptedException e) {e.printStackTrace();}
			   }
		
		sweepViewGui.loadCSVFile("experiment.csv", "Partial ");
		
	   }
}		   